package com.jjw.route.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jjw.route.entity.PortraitEntity;
import com.jjw.route.service.PortraitService;
import com.jjw.route.utils.PageUtils;
import com.jjw.route.utils.R;



/**
 * 
 *
 * @author jjw
 * @email 2371671097@qq.com
 * @date 2023-05-12 07:45:21
 */
@RestController
@RequestMapping("route/portrait")
@CrossOrigin
public class PortraitController {
    @Autowired
    private PortraitService portraitService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("route:portrait:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = portraitService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("route:portrait:info")
    public R info(@PathVariable("id") Integer id){
		PortraitEntity portrait = portraitService.getById(id);
        return R.ok().put("portrait", portrait);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("route:portrait:save")
    public R save(@RequestBody PortraitEntity portrait){
		portraitService.save(portrait);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("route:portrait:update")
    public R update(@RequestBody PortraitEntity portrait){
		portraitService.updateById(portrait);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("route:portrait:delete")
    public R delete(@RequestBody Integer[] ids){
		portraitService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
